<?php

namespace App\Rules;

use Illuminate\Contracts\Validation\Rule;

class ContentXss implements Rule
{
    /**
     * Create a new rule instance.
     *
     * @return void
     */
    public function __construct()
    {
        //
    }

    /**
     * 如：['content' => '12312']
     *
     * @param  string  $attribute : content
     * @param  mixed  $value : 12312
     * @return bool
     */
    public function passes($attribute, $value)
    {
        // 得到xss过滤后的内容
        $value = clean($value, 'user_topic_body');
        return !empty($value);
    }

    /**
     * Get the validation error message.
     *
     * @return string
     */
    public function message()
    {
        return '内容错误~';
    }
}
